<template>
  <div class="jingpin">
    <div class="top">
      <span>{{ title }}</span>
      <span>更多</span>
    </div>
    <div class="body">
      <ul class="left">
        <li
          :class="{ cur: cur == i }"
          v-for="(v, i) in arr"
          :key="i"
          @click="cur = i"
        >
          {{ v }}
        </li>
      </ul>
      <div class="right">
        <rai-jingpin-zujian :data="x ? data.slice(0, 10) : data" />
      </div>
    </div>
    <div class="footer">
      <div v-show="x" @click="zk">
        展开更多&nbsp;
        <span>"{{ arr[cur] }}"</span>&nbsp; 栏目视频 ↓
      </div>
      <div v-show="!x" @click="sq">收起 ↑</div>
    </div>
  </div>
</template>

<script>
import RaiJingpinZujian from "./RaiJingpinZujian.vue";
export default {
  components: { RaiJingpinZujian },
  data() {
    return {
      cur: 0,
      data: [],
      x: 1,
    };
  },
  watch: {
    cur(n) {
      if (n == 0) {
        this.get(932);
      } else if (n == 1) {
        this.get(5090);
      } else if (n == 2) {
        this.get(1855);
      } else if (n == 3) {
        this.get(4648);
      } else if (n == 4) {
        this.get(4781);
      } else if (n == 5) {
        this.get(4782);
      } else if (n == 6) {
        this.get(1809);
      } else if (n == 7) {
        this.get(4780);
      }
    },
  },
  props: ["arr", "title"],
  mounted() {
    this.get(932);
  },
  methods: {
    zk() {
      this.x = 0;
    },
    sq() {
      this.x = 1;
      console.log(this.x);
    },
    get(n) {
      this.axios
        .get(
          "/api/cmc/cross?serviceId=18&filter=tag&sortby=sIdxTime&source=web_pc&limit=20&logic=or&typeids=1%2C2&exclusiveChannel=4&exclusiveChannelSign=7862b2fcbb0098240942799136917793&time=1649479922&tagids=" +
            n
        )
        .then((res) => {
          console.log(res.data.data.items, 9999999999);
          this.data = res.data.data.items;
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.jingpin {
  margin: 40px auto 0 auto;
  width: 1200px;
  .top {
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    > span {
      background-image: url("/public/img/icon-bg.png");
      background-repeat: no-repeat;
      &:first-child {
        background-position: -8px -147px;
        font-size: 21px;
        font-weight: bold;
        padding-left: 28px;
      }
      &:last-child {
        background-position: -11px -44px;
        font-size: 14px;
        color: gray;
        padding-left: 20px;
      }
    }
  }
  .body {
    display: flex;
    justify-content: space-between;
    .left {
      width: 188px;
      height: 356px;
      border: 2px solid rgb(225, 225, 225);
      background-color: rgb(245, 245, 245);
      li {
        cursor: pointer;
        line-height: 40px;
        font-size: 14px;
        text-align: center;
        color: rgb(102, 102, 102);
        &.cur {
          background-color: rgb(243, 194, 88);
          color: white;
          font-weight: bold;
        }
      }
    }
    .right {
      width: 1022px;
      //   height: 500px;
      //   border: 1px solid red;
    }
  }
  .footer {
    color: gray;
    &:hover {
      background-color: rgb(237, 237, 237);
      & span {
        text-decoration: underline;
      }
    }
    cursor: pointer;
    line-height: 40px;
    background-color: rgb(245, 245, 245);
    text-align: center;
    span {
      color: orange;
    }
  }
}
</style>